package game.entity.action;

import edu.monash.fit2099.engine.*;
import game.entity.actor.Brachiosaur;
import game.util.LocationUtil;

import java.util.Random;

/**
 * Special Action for attacking other Actors.
 */
public class EatAction extends Action {

	/**
	 * The Actor that is to be attacked
	 */
	protected Item target;

	private Ground ground;
	/**
	 * Random number generator
	 */
	protected Random rand = new Random();

	/**
	 * Constructor.
	 *
	 * @param target the Actor to attack
	 */
	public EatAction(Item target) {
		this.target = target;
	}


	@Override
	public String execute(Actor actor, GameMap map) {

		Location location = map.locationOf(actor);
		if(target!=null){
			//每种水果只增加5点饥饿值，因为它们消化效果不好
			if(actor instanceof Brachiosaur){
				actor.heal(5);
			}else{
				actor.heal(10);
			}
			map.locationOf(actor).removeItem(target);
			actor.removeItemFromInventory(target);
			return LocationUtil.getLocationPrettyString(location) + actor +" heal 10 hp after eating fruit,now hp:"+actor.getHitPoints();
		}
		return "nothing to eat ";
	}

	@Override
	public String menuDescription(Actor actor) {
		return actor + " eat " + target;
	}


}
